﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TaiLieu;

public partial class localhost : System.Web.UI.UserControl
{
    public string _Query;
    string login = "";

    protected void Page_Load(object sender, EventArgs e)
    {
        _Query = QueryHelper.Get_Domain_1(Request);
        login = "<a href=\"?/login\" style=\"color: Orange; font-size: 13px; font-family: Tahoma; text-decoration: none\"><span>Đăng nhập&nbsp;</span></a><a href=\"?/register\" style=\"color: Orange; font-size: 13px; font-family: Tahoma;text-decoration: none\"><span>/&nbsp; Đăng ký</span></a>";
        TaiLieu();
        userInfomation();
    }
    protected void LoadControlCenter(string path)
    {
        this.pnContext.Controls.Clear();
        this.pnContext.Controls.Add(LoadControl(path));
    }
    public void TaiLieu()
    {
        switch (QueryHelper.Get_Value(Request, 1))
        {
            case "trang-chu":
                LoadControlCenter("trang-chu/tl_trang-chu.ascx");
                break;
            case "gioi-thieu":
                LoadControlCenter("gioi-thieu/tl_GioiThieu.ascx");
                break;
            case "trac-nghiem":
                LoadControlCenter("trac-nghiem/trac-nghiem.ascx");
                break;
            case "tai-lieu":
                LoadControlCenter("TaiLieu/tai-lieu.ascx");
                break;
            case "member":
                LoadControlCenter("Member/Member.ascx");
                break;
            case "search":
                LoadControlCenter("search/search_content.ascx");
                break;
            default:
                LoadControlCenter("trang-chu/tl_trang-chu.ascx");
                break;
        }
    }
    public void userInfomation()
    {
        if (Request.Cookies["remember"] != null)
        {
            HttpCookie cookie = Request.Cookies.Get("idmembergiaoducanbinh");
            if (cookie != null)
                Sessions.members = MembersDB.login(cookie.Values["UserName"].ToString(), cookie.Values["Password"].ToString());
        }
        if (Sessions.members == null)
        {
            this.pnuser.Controls.Clear();
            this.pnuser.Controls.Add(LoadControl("Member/login_1.ascx"));
        }
        else
        {
            this.pnuser.Controls.Clear();
            this.pnuser.Controls.Add(LoadControl("Member/infomationUser.ascx"));
        }
    }
}